#include <iostream>
#include <unistd.h>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <pthread.h>

void *routine(void *args)
{
    std::string name = static_cast<char *>(args);
    int cnt = 10;
    int a = 0;
    while(cnt--)
    {
        std::cout<<"我是一个新线程, 我的name: "<<name<<std::endl;

        if(cnt == 5)
        {
            a/=0;
        }
        sleep(1);
    }
    return nullptr;
}

int main()
{
    pthread_t tid;
    int n = pthread_create(&tid, nullptr, routine, (void*)"thread-1");

    while(true)
    {
        std::cout<<"我是main线程!"<<std::endl;
        sleep(1);
    }
    return 0;
}